<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      console.log(1)

      setTimeout(function () {
        console.log(2)
        new Promise(function (resolve) {
          console.log(3)
          resolve()
        }).then(function () {
          console.log(4)
        })
      })

      const p = new Promise((resolve, reject) => {
        console.log(5)
        resolve() // 标记为成功
        console.log(6)
      })

      p.then(data => {
        console.log(7)
      })

      console.log(8)
      /*
        打印结果
        1. 第一轮打印 定时器,then收起来 
          1 5 6 8
        2. 第二轮打印 打开then 微
          7
        3. 第三轮打开 定时器 宏
         2 3 4

        只会出现在 面试题, 笔试题
         问你如下代码的输出结果
      */
    </script>
  </body>
</html>
